<%@page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<%@taglib prefix="html" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<html:header title="登录-进销存系统"
             keywords=""
             description="">
    <link rel="stylesheet" href="${baseUrl}css/login.css" media="all">

    <script src="${baseUrl}lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
    <script>
        layui.use(['form'], function () {
            var form = layui.form,
                layer = layui.layer;

            // 登录过期的时候，跳出ifram框架
            if (top.location != self.location) top.location = self.location;

            // 粒子线条背景
            $(document).ready(function(){
                $('.layui-container').particleground({
                    dotColor:'#5cbdaa',
                    lineColor:'#5cbdaa'
                });
            });

            // 进行登录操作
            form.on('submit(login)', function (data) {
                data = data.field;
                if (data.username == '') {
                    $("#errMsg").html('账号不能为空');
                    return false;
                }

                if (data.password == '') {
                    $("#errMsg").html('密码不能为空');
                    return false;
                }

                if(data.validateCode == '') {
                    $("#errMsg").html('验证码不能为空');
                    return false;
                }
                tipLoad();
                <%--post("${baseUrl}login/login.action",data,function (res) {--%>
                <%--    closeAll();--%>
                <%--    if (res.code == 2){--%>
                <%--        $("#captchaPic").click();--%>
                <%--        $("#errMsg").html(res.msg);--%>
                <%--    } else {--%>
                <%--        $("#errMsg").html("");--%>
                <%--        window.location.href = "${baseUrl}home.action";--%>
                <%--    }--%>
                <%--});--%>
                return true;
            });
            

            $("#captchaPic").click(function () {
                $("#captchaPic").attr("src","${baseUrl}validateCode.jsp?time="+new Date().getTime());
            });
            
            $("#register").click(function () {
                //跳转到注册页面
                window.location.href = "${baseUrl}register/page.action";
            });

        });
    </script>

</html:header>
<body>
<div class="layui-container">
    <div class="admin-login-background">
        <div class="layui-form login-form">
            <form class="layui-form" action="${baseUrl}login/login.action" method="post">
                <div class="layui-form-item logo-title">
                    <h1>进销存系统</h1>
                </div>
                <div class="layui-form-item">
                    <span id="errMsg" style="color:#FF5722;font-size: 14px;">${errMsg}</span>
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-username"></label>
                    <input type="text" name="username" value="${username}"  placeholder="账号/手机" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-password" ></label>
                    <input type="password" name="password" value="${password}"  placeholder="密码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-vercode" for="validateCode"></label>
                    <input type="text" name="validateCode" lay-verify="validateCode" placeholder="图形验证码" autocomplete="off" class="layui-input verification captcha" value="">
                    <div class="captcha-img">
                        <img id="captchaPic" src="${baseUrl}validateCode.jsp">
                    </div>
                </div>
<%--                <div class="layui-form-item">--%>
<%--                    <input type="checkbox" name="rememberMe" value="true" lay-skin="primary" title="记住密码">--%>
<%--                </div>--%>
                <div class="layui-form-item">
                    <button style="margin-right: 4px;" class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="login">登 录</button>
                </div>

                <div class="layui-form-item">
                    <span style="font-size: 14px;color: #393D49; padding-right: 4px;">没有账号?</span>
                    <a href="${baseUrl}register/page.action" style="font-size: 14px;color: #009688;text-decoration: none;">立即注册</a>
                </div>
            </form>
        </div>
    </div>
</div>

</body>

<html:loading tip="登录中....."/>
</html>